<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="renderer" content="webkit"/>
<meta name="force-rendering" content="webkit"/>
<title></title>
<link type="text/css" rel="stylesheet" href="css/style.css" />
<script type="text/javascript" src="../lib/layui-v2.6.3/jquery-1.8.2.min.js" charset="utf-8"></script>
<script type="text/javascript">
$(document).ready(function () {
   var height=$(document).height();
   $('body').css('height',height);
   var mart=height-500;
   mart = mart/2;
   $('.loginBox').css('marginTop',mart);
})
</script>
</head>

<body>
<!--action="/login" method="post"-->
<form class="layui-form" lay-filter="loginForm" >
<div class="loginBox">
  <h1>欢迎登陆</h1>
  <div class="item">
    <div class="icon"><img src="images/icon1.png" /></div>
    <div class="txt"><input name="username" type="text" placeholder="请输入您的用户名" value="admin"/></div>
  </div>
  <div class="item">
    <div class="icon"><img src="images/icon2.png" /></div>
    <div class="txt"><input name="password" type="password" placeholder="请输入您的密码" value="123"/></div>
  </div>

  <div class="item">
    <div class="icon"><img src="images/icon3.png" /></div>
    <div class="txt"><input name="captcha" type="text" placeholder="请输入验证码" value="123"/></div>
    <div class="yzm"><img id="refreshCaptcha"  src="/image"></div>
  </div>

  <div class="item_2">
    <input name="" type="checkbox" value="" />
    <span>记住密码</span>
    <a href="/psd">忘记密码？</a>
  </div>
  <div class="item_3">
    <input id="msg" type="hidden">
    <input name="" type="button" value="安全登录" class="btn" id="safeLogin"/>
  </div>
<!--  <div class="item_4">-->
<!--    还没有账号？<a href="/register">立即注册</a>-->
<!--  </div>-->
</div>
</form>

<script src="../lib/layui-v2.6.3/layui.js" charset="utf-8"></script>
<script>
  layui.use(['form','jquery','form','layer'], function () {
    var form = layui.form, layer = layui.layer;
    var $ = layui.jquery;
    //登录按钮绑定事件
    $("#safeLogin").on("click",function (){
      var data = form.val("loginForm");
      $.post("/login",data,function (res){//先检查-错误提示
        if (res.code==0) {
          window.top.location.href=res.data;
        }
        layer.msg(res.msg);
      });
    });

    //给验证码图片绑定事件
    $("body").on("click", "#refreshCaptcha", function () {
      this.src = "/image?img=" + Math.random();
    });
  });

</script>
</body>
</html>
